<template>
	<div class="journal">
		<ul v-loading='loading'>
			<li class="journal-list clear" v-for="item of journalList" :key="item.id">
				<router-link :to="{path: '/teach/see', query: {id: item.id,teacherId: create_id}}">{{item.name}}</router-link>
				<i>{{item.create_time.substr(0,11)}}</i>
			</li>
		</ul>
		<el-pagination v-if="total_sum > page_size"
			class="pageing"
			@current-change="SizeChange"
			:current-page="page_index"
			:page-size="page_size"
			layout="total, prev, pager, next,jumper"
			:total="total_sum">
		</el-pagination>
		<div class="dependent" v-if="placeholder">
			<i class="ipng image_state01"></i>
			<p>还没发现任何相关的内容哦~</p>
		</div>
	</div>
</template>

<script>
	
	export default{
		data(){
			return {
				page_index: 1,
				page_size: 12,
				total_sum: 0,
				loading: true,
				placeholder: false,
				journalList: [],
				create_id: this.$route.query.id,
			}
		},
		created(){
			this.getjournalList()
		},
		methods: {
			getjournalList(){
				let success = (res =>{
					this.journalList = res.data.data;
					this.total_sum = parseInt(res.data.data_sum)

					this.loading = false;
					this.placeholder = this.journalList.length === 0 ? true : false
				});
				// this.$ajax({
				// 	url: 'api/resource/journal',
				// 	method: 'get',
				// 	params: {
				// 		page: this.page_index,
				// 		size: this.page_size,
				// 		create_id: this.$route.query.id,
				// 		data_type: 2,
				// 		status: 1,
				// 		authority: 1,
				// 		is_diffplat: 1
				// 	},
				// 	func: {success: success}
				// })


				if (this.$g.user_id == this.$route.query.id) {
					this.$ajax.get('api/resource/journal',{
						params: {
							type:2,
							create_id: this.$route.query.id,
							size: this.size,
							page:this.page,
							data_type:2,
							orderby:'id',
							orderby_desc:1,
							stutas: '1,2,3',
						},
						func:{success:success}
					})
				}else{
					this.$ajax.get('api/resource/journal',{
						params: {
							type:2,
							create_id: this.$route.query.id,
							size: this.size,
							page:this.page,
							data_type:2,
							authority:1,
							orderby:'id',
							orderby_desc:1,
							stutas: '1',
							authority:1
						},
						func:{success:success}
					})
				}
			},
			SizeChange(val) {
				this.page_index = val;
				this.getjournalList()
				// console.log(`每页 ${val} 条`);
			}
		},
	}
</script>